package cn.donting.jme.inspect;

import cn.donting.jme.EditorContent;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class InspectBuilder {


    public static Inspect create(Object obj) {
        long l = System.currentTimeMillis();
        try {
            Inspect inspect = new Inspect(obj);
            List<cn.donting.jme.expansion.inspect.InspectBuilder> groupBuilders = EditorContent.getIocContainer().getBeansByTypes(cn.donting.jme.expansion.inspect.InspectBuilder.class);
            for (cn.donting.jme.expansion.inspect.InspectBuilder groupBuilder : groupBuilders) {
                if (groupBuilder.isHandle(obj)) {
                    groupBuilder.builder(inspect, obj);
                }
            }
            log.info("InspectBuilder 耗时：{}",System.currentTimeMillis()-l);
            System.out.println("InspectBuilder 耗时:"+(System.currentTimeMillis()-l));
            return inspect;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new RuntimeException(ex.getMessage(),ex);
        }
    }


}
